﻿using System.Data;
using l1cs.server.model.Instance;
using l1cs.server.utils;

namespace l1cs.server.model.trap
{
    class L1TeleportTrap : L1Trap
    {
        private readonly L1Location _loc;

        public L1TeleportTrap( DataRow item )
            : base( item )
        {
            int x = SqlUtils.toInt( item["teleportX"] );
            int y = SqlUtils.toInt( item["teleportY"] );
            int mapId = SqlUtils.toInt( item["teleportMapId"] );
            _loc = new L1Location( x, y, mapId );
        }

        override public void onTrod( L1PcInstance trodFrom, L1Object trapObj )
        {
            sendEffect( trapObj );

            L1Teleport.teleport( trodFrom, _loc.getX(), _loc.getY(), (short)_loc.getMapId(), 5, true );
        }
    }
}
